package com.example.controller;

import com.example.domain.Goods;
import com.example.domain.Option;
import com.example.domain.Result;
import com.example.service.GoodsService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController extends BaseController {

    @Autowired
    private GoodsService goodsService;

    /**
     * 货物下拉框数据
     */
    @GetMapping("/options")
    public Result options() {

        List<Option> optionsList = goodsService.selectGoodsOptions();
        return success(optionsList);
    }

    /**
     * 列表
     */
    @GetMapping("/list")
    public Result list(Goods goods) {
        PageInfo<Goods> page = this.goodsService.selectGoodsPageList(goods);
        return success(page);
    }
}
